package com.yue.ssa.controller;

import com.yue.ssa.service.UserRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@Api(value = "用户角色映射管理", tags = "用户角色映射管理")
@RestController
@RequestMapping("rest/userRole")
public class UserRoleController {

    @Autowired
    private UserRoleService userRoleService;

    @PreAuthorize("hasAuthority('system_user::write')")
    @ApiOperation(value = "分配角色", notes = "分配角色")
    @ApiImplicitParams({@ApiImplicitParam(name = "uid", value = "用户主键", required = true, dataType = "String"),
            @ApiImplicitParam(name = "rids", value = "角色主键数组", required = true, allowMultiple = true, dataType = "String")})
    @GetMapping("/assignRoles")
    public boolean assignRoles(@RequestParam String uid, @RequestParam String[] rids) {
        return userRoleService.assignRoles(uid, rids);
    }
}
